package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteLogisticsService;
import com.ruoyi.system.api.domain.TraceTransport;
import com.ruoyi.system.api.domain.vo.CropsVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author five
 */
@Component
public class RemoteLogisticsFallbackFactory implements FallbackFactory<RemoteLogisticsService> {

    public static final Logger log = LoggerFactory.getLogger(RemoteLogisticsFallbackFactory.class);

    @Override
    public RemoteLogisticsService create(Throwable throwable) {
        log.error("物流服务调用失败:{}", throwable.getMessage());
        return new RemoteLogisticsService() {

            @Override
            public R<List<TraceTransport>> listCrops(String deptId, String source) {
                return R.fail("调用查询列表失败:" + throwable.getMessage());
            }

            @Override
            public R<List<CropsVo>> queryCropsList(Integer deptId, String source) {
                return R.fail("调用两表查询列表失败:" + throwable.getMessage());
            }

            @Override
            public R<Integer> changeInToOut(String cropsId, String source) {
                return R.fail("调用出库失败:" + throwable.getMessage());
            }

            @Override
            public R<Integer> addTransport(TraceTransport traceTransport, String source) {
                return R.fail("调用添加任务失败:" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateReceiveStatus(TraceTransport traceTransport, String source) {
                return R.fail("调用更新接收状态失败:" + throwable.getMessage());
            }
        };
    }


}
